﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace UserSystem
{
    public class UserService : IUserService
    {
        private readonly IUnitOfWork _unitOfWork;

        public UserService(IUnitOfWork unitOfWork)
        {
            _unitOfWork = unitOfWork;
        }

        public int UserLogin(string userName, string password)
        {
            var user = _unitOfWork.Repository<User>().FirstOrDefault(x => x.UserName == userName);
            if (user != null && user.Password == password)
            {
                return user.UserId;
            }
            return 0;
        }
    }
}
